﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NewDDSys.Entity;
using NewDDSys.Factory;
using NewDDSys.IBLL;
using System.Data;

namespace NewDDSys.BLL
{
    public class WorkBLL:IWorkBLL
    {
        public int AddWork(WorkInfo work)
        {
            return DALFactory.CreateWorkDAL().AddWork(work);
        }

        public int UpdateWork(string num, string banbie, string banzu, decimal dun, string neirong, int good, int bad, string pos, int pb, int cc, int qh, int wcs, string yuanyin)
        {
            return DALFactory.CreateWorkDAL().UpdateWork(num, banbie, banzu, dun, neirong, good, bad, pos, pb, cc, qh, wcs, yuanyin);
        }

        public int UpdateWorkYuanyin(string num, string yuanyin)
        {
            return DALFactory.CreateWorkDAL().UpdateWorkYuanyin(num, yuanyin);
        }
        public int UpdateKX(string num, decimal kx)
        {
            return DALFactory.CreateWorkDAL().UpdateKX(num, kx);
        }
        public int Del(string num)
        {
            return DALFactory.CreateWorkDAL().Del(num);
        }
        public string AUTOID(string ku)
        {
            return DALFactory.CreateWorkDAL().AUTOID(ku);
        }
        public DataSet Select(string num)
        {
            return DALFactory.CreateWorkDAL().Select(num);
        }
        public DataSet SelectByDay(string sday)
        {
            return DALFactory.CreateWorkDAL().SelectByDay(sday);
        }
        public DataSet SelectZW(string ku)
        {
            return DALFactory.CreateWorkDAL().SelectZW(ku);
        }
        public DataSet SelectKN(string ku)
        {
            return DALFactory.CreateWorkDAL().SelectKN(ku);
        }
        public DataSet SelectBySta(string ku, string sta)
        {
            return DALFactory.CreateWorkDAL().SelectBySta(ku, sta);
        }
        public DataSet workcd(string ku, string neirong)
        {
            string sta = "";
            if (neirong == "零提")
                sta = "装完";
            else
                sta = "封完";
            string banbie = DALFactory.CreateJbDAL().banbieNow();
            string cday = DateTime.Now.ToShortDateString().ToString();
            string btime = "";
            string etime = "";
            if (banbie == "白")
            {
                btime = cday + "08:00:00";
                etime = cday + "20:00:00";
            }
            else
            {
                etime = cday + "08:00:00";
                DateTime jstime = Convert.ToDateTime(cday).AddHours(8);
                DateTime kstime = jstime.AddDays(-0.5);
                btime = kstime.ToString();
            }
            DataSet ds = DALFactory.CreateWorkDAL().jbdc(ku, btime, etime, sta, neirong);
            return ds;
        }
        public decimal kxtj(string ku, string pdtime)
        {
            if (DALFactory.CreateWorkDAL().HaveJL(ku))
            {
                string fw = DALFactory.CreateWorkDAL().zhfw(ku);

                TimeSpan ts = Convert.ToDateTime(pdtime) - Convert.ToDateTime(fw);
                return Convert.ToDecimal(ts.TotalHours);
            }
            else
                return 0;
        }
        public DataSet dbck(string ku, string cday)
        {
            
            return DALFactory.CreateWorkDAL().ckd(cday, ku);
        }
        public string wfbykpdb(string ku, string cday, string banbie)
        {
            return DALFactory.CreateWorkDAL().bwf(banbie, ku, cday);
        }


        public DataSet cdbykpz(string ku, string neirong, string cday)
        {
            
            return (DALFactory.CreateWorkDAL().dkqk(cday, ku, neirong));
        }
        public int UpdateZcys(string num, decimal ys)
        {
            return DALFactory.CreateWorkDAL().UpdateZcys(num, ys);
        }
        public int UpdateYs(string num, decimal ys)
        {
            return DALFactory.CreateWorkDAL().UpdateYs(num, ys);
        }
        public DataSet SelectZYQK()
        {
            return DALFactory.CreateWorkDAL().SelectZYQK();
        }
        public string csbyzk(string neirong, string ku)
        {
            return DALFactory.CreateWorkDAL().csbyzk(neirong, ku);
        }
        public string csbyzkH(string bt, string et, string neirong, string ku)
        {
            return DALFactory.CreateWorkDAL().csbyzkH(bt, et, neirong, ku);
        }
        
        public string yshj()
        {
            return DALFactory.CreateWorkDAL().yshj();
        }
        public int UpdateDX(string num, int dx)
        {
            return DALFactory.CreateWorkDAL().UpdateDX(num, dx);
        }
        public int UpdateGood(string num, int good)
        {
            return DALFactory.CreateWorkDAL().UpdateGood(num, good);
        }
        public int UpdateBad(string num, int bad)
        {
            return DALFactory.CreateWorkDAL().UpdateBad(num, bad);
        }
        public int UpdatePb(string num, int pb)
        {
            return DALFactory.CreateWorkDAL().UpdatePb(num, pb);
        }
        public int UpdateCc(string num, int cc)
        {
            return DALFactory.CreateWorkDAL().UpdateCc(num, cc);
        }
        public int UpdateQh(string num, int qh)
        {
            return DALFactory.CreateWorkDAL().UpdateQh(num, qh);
        }
        public int UpdateWcs(string num, int wcs)
        {
            return DALFactory.CreateWorkDAL().UpdateWcs(num, wcs);
        }
        public int UpdateZw(string num, string zw)
        {
            return DALFactory.CreateWorkDAL().UpdateZw(num, zw);
        }
        public int UpdateFw(string num, string fw)
        {
            return DALFactory.CreateWorkDAL().UpdateFw(num, fw);
        }
        public int UpdateGc(string num, string gc)
        {
            return DALFactory.CreateWorkDAL().UpdateGc(num, gc);
        }
        public int UpdateSta(string num, string sta)
        {
            return DALFactory.CreateWorkDAL().UpdateSta(num, sta);
        }
        public DataSet nld(string neirong, string ku, string cday)
        {
            return DALFactory.CreateWorkDAL().nld(neirong, ku, cday);
        }
        public DataSet timetj(string ku, string cday)
        {
            return DALFactory.CreateWorkDAL().timetj(ku, cday);
        }
        
        
        
        public string FristDay()
        {
            return DALFactory.CreateWorkDAL().FristDay();
        }
        public string GoodHJ(string cday)
        {
            return DALFactory.CreateWorkDAL().GoodHJ(cday);
        }
        public string BadHJ(string cday)
        {
            return DALFactory.CreateWorkDAL().BadHJ(cday);
        }
        public string WFHJ(string cday)
        {
            return DALFactory.CreateWorkDAL().WFHJ(cday);
        }
        public string LTHJ(string cday)
        {
            return DALFactory.CreateWorkDAL().LTHJ(cday);
        }
        public string RDK(string cday)
        {
            return DALFactory.CreateWorkDAL().RDK(cday);
        }
        public int UpdatePD(string num, string banbie, string banzu, decimal dun, string neirong, int good, int bad, string pos, int pb, int cc, int qh, string pdtime)
        {
            return DALFactory.CreateWorkDAL().UpdatePD(num, banbie, banzu, dun, neirong, good, bad, pos, pb, cc, qh, pdtime);
        }
        
        public int UpdateFW(string num, string fwtime, string yuanyin)
        {
            return DALFactory.CreateWorkDAL().UpdateFW(num, fwtime, yuanyin);
        }
        public string YGoodHJ(string bt, string et)
        {
            return DALFactory.CreateWorkDAL().YGoodHJ(bt, et);
        }
        public string YBadHJ(string bt, string et)
        {
            return DALFactory.CreateWorkDAL().YBadHJ(bt, et);
        }
        public string YWF(string bt, string et)
        {
            return DALFactory.CreateWorkDAL().YWF(bt, et);
        }
        public string YDK(string bt, string et)
        {
            return DALFactory.CreateWorkDAL().YDK(bt, et);
        }
        public string YLT(string bt, string et)
        {
            return DALFactory.CreateWorkDAL().YLT(bt, et);
        }
        public string CKL(string cday, string ku)
        {
            return DALFactory.CreateWorkDAL().CKL(cday, ku);
        }
        public string ltyshj(string cday)
        {
            return DALFactory.CreateWorkDAL().ltyshj(cday);
        }
        public DataSet JDWF(string cday)
        {
            return DALFactory.CreateWorkDAL().JDWF(cday);
        }
        public DataSet JDLT(string cday)
        {
            return DALFactory.CreateWorkDAL().JDLT(cday);
        }
        public string JDDK(string cday)
        {
            return DALFactory.CreateWorkDAL().JDDK(cday);
        }
        public DataSet DBZY(string ku, string banzu)
        {
            return DALFactory.CreateWorkDAL().DBZY(ku, banzu);
        }
        public DataSet ZYQTJ(string kday, string eday, string ku, string neirong)
        {
            return DALFactory.CreateWorkDAL().ZYQTJ(kday, eday, ku, neirong);
        }
        public DataSet BTJ(string kday, string eday, string ku, string banzu, string neirong)
        {
            return DALFactory.CreateWorkDAL().BTJ(kday, eday, ku, banzu, neirong);
        }
        public string JDCS(string bt, string et, string neirong)
        {
            return DALFactory.CreateWorkDAL().JDCS(bt, et, neirong);
        }
        public DataSet SelectZYQKH(string bt, string et)
        {
            return DALFactory.CreateWorkDAL().SelectZYQKH(bt, et);
        }
    }
}
